using System.Collections;
using System.Collections.Generic;
using QFramework;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;


namespace AsterroidX
{
    public class AddScoreCmd : AbstractCommand
    {

        private int mScore;

        public AddScoreCmd(int score)
        {
            mScore = score;
        }
        protected override void OnExecute()
        {
            var gameModel = this.GetModel<GameModel>();

            gameModel.Score.Value += mScore;

            if (gameModel.Score.Value > gameModel.BestScore.Value)
            {
                gameModel.BestScore.Value = gameModel.Score.Value;
                var storage = this.GetUtility<StorageUtility>();
                storage.SaveInt(nameof(gameModel.BestScore), gameModel.BestScore.Value);
            }
        }
    }

}
